/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Updater.java
 *
 * Created on 29/Ago/2009, 19:58:08
 */

package barreirasacscomunicator.gui;

import barreirasacscomunicator.BACSComunicator;
import java.awt.Dimension;
import java.awt.Toolkit;

/**
 *
 * @author rjsantos
 */
public class Updater extends javax.swing.JFrame {




    /** Creates new form Updater */
    public Updater() {

        

        initComponents();


        Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
        this.setLocation((dim.width/2)-(this.getSize().width/2), (dim.height/2)-(this.getSize().height/2));

    }

    public void setTotal(int tot){

        jProgressBarUpdate.setMaximum(tot);
    }

    public void setDone(int don){

        jProgressBarUpdate.setValue(don);

        if(jProgressBarUpdate.getMaximum()==jProgressBarUpdate.getValue()){
            jButtonUpdate.setText("Fechar!");
            jButtonUpdate.setEnabled(true);
            jTextPaneMessage.setText(jTextPaneMessage.getText() + "\n\n"+ "Para Concluir a actualização tem de reiniciar a aplicação");
        }

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jProgressBarUpdate = new javax.swing.JProgressBar();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextPaneMessage = new javax.swing.JTextPane();
        jButtonUpdate = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jTextPaneMessage.setBackground(new java.awt.Color(240, 240, 240));
        jTextPaneMessage.setBorder(javax.swing.BorderFactory.createCompoundBorder());
        jTextPaneMessage.setEditable(false);
        jTextPaneMessage.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jTextPaneMessage.setText("É verdade isto até se actualiza sozinho. Tem de ser porque isto vai tar sempre a ser melhorado.");
        jScrollPane1.setViewportView(jTextPaneMessage);

        jButtonUpdate.setText("Aguarde...");
        jButtonUpdate.setEnabled(false);
        jButtonUpdate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonUpdateActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jProgressBarUpdate, javax.swing.GroupLayout.DEFAULT_SIZE, 333, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 333, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(114, Short.MAX_VALUE)
                .addComponent(jButtonUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(105, 105, 105))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jProgressBarUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(11, 11, 11)
                .addComponent(jButtonUpdate)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonUpdateActionPerformed
        // TODO add your handling code here:

        System.exit(0);


    }//GEN-LAST:event_jButtonUpdateActionPerformed



    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonUpdate;
    private javax.swing.JProgressBar jProgressBarUpdate;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextPane jTextPaneMessage;
    // End of variables declaration//GEN-END:variables

}
